<?php

class Silk_Mapi_Block_Adminhtml_Version_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
{
    protected function _prepareForm()
    {

        $form = new Varien_Data_Form();
        $this->setForm($form);

        $fieldset = $form->addFieldset("app_version_form", array("legend" => Mage::helper("mapi")->__("版本信息")));

        $fieldset->addField("title", "text", array(
            "label" => Mage::helper("mapi")->__("名称"),
            "class" => "required-entry",
            "required" => true,
            "name" => "title",
        ));

        $fieldset->addField("type", "select", array(
            "label" => Mage::helper("mapi")->__("APP类型"),
            "class" => "required-entry",
            "required" => true,
            'values' => Mage::helper('mapi')->getAppType(),
            "name" => "type",
        ));


        $fieldset->addField("version", "text", array(
            "label" => Mage::helper("mapi")->__("版本号"),
            "class" => "required-entry",
            "required" => true,
            "name" => "version",
        ));

        $fieldset->addField("url", "text", array(
            "label" => Mage::helper("mapi")->__("安装包路径"),
            "class" => "required-entry",
            "required" => true,
            "name" => "url",
        ));

        $fieldset->addField("website_ids", "multiselect", array(
            "label" => Mage::helper("mapi")->__("站点"),
            "class" => "required-entry",
            "required" => true,
            //'value' => 1,
            'values' => Mage::getSingleton('adminhtml/system_store')->getWebsiteValuesForForm(),
            "name" => "website_ids[]",
        ));

        $fieldset->addField("status", "select", array(
            "label" => Mage::helper("mapi")->__("状态"),
            "class" => "required-entry",
            "required" => true,
            'value' => 1,
            'values' => array('1' => '启用', '0' => '禁用'),
            "name" => "status",
        ));

        $fieldset->addField("force", "select", array(
            "label" => Mage::helper("mapi")->__("强制更新"),
            "class" => "required-entry",
            "required" => true,
            'values' => array('0' => '否', '1' => '是'),
            "name" => "force",
        ));

        $fieldset->addField("note", "textarea", array(
            "label" => Mage::helper("mapi")->__("备注"),
            "name" => "note",
        ));


        if (Mage::getSingleton("adminhtml/session")->getVersionData()) {
            $form->setValues(Mage::getSingleton("adminhtml/session")->getVersionData());
            Mage::getSingleton("adminhtml/session")->setVersionData(null);
        }

        return parent::_prepareForm();
    }
}
